package com.example.demo.controller;

import com.example.demo.entity.Admin;
import com.example.demo.entity.ResponseResult;
import com.example.demo.service.AdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/admin")
@Api(tags = "管理员接口")
public class AdminController {

    @Resource
    private AdminService adminService;

    @GetMapping
    @ApiOperation(value = "管理员登录")
    public ResponseResult login(@RequestBody Admin admin){
        // 根据里面的账号和密码进行校验
        Admin admin1 = adminService.login(admin);
        if(admin1 != null)
            return ResponseResult.ok("登录成功");
        return ResponseResult.fail("登录账号或密码错误");
    }
}
